#ifndef OP_BE_GROUP_BY_H
#define OP_BE_GROUP_BY_H

#include <cstddef>
#include "Op.h"
#include "proto/internal.pb.h"

class OpBEGroupBy: public Op {
public:
  typedef std::vector<char*> RowsList;
private:
  	Op* source;
  	Output by_column;
  	Output aggregated_column;
  	size_t by_size, row_size;
    RowsList rows;
  	char* next_row, *end_row;
  	
public:
	OpBEGroupBy(const internal::BEGroupByOperation& operation);

	int doit();
	
	size_t getRowSize() {
		return row_size;
	}
	RowsList* getDoItResultRows() {
		return &rows;
	}
	char* getLast() {
		return next_row;
	}

private:
	void allocate_next_rows();
};

#endif
